wayland: Store the device that does a grab for a window on the window
authorRob Bradford <rob@linux.intel.com>
Mon, 27 Feb 2012 14:06:22 +0000 (14:06 +0000)
committerRob Bradford <rob@linux.intel.com>
Mon, 27 Feb 2012 17:15:12 +0000 (17:15 +0000)
This allows us to get the device if we need to make the window a popup. This
relies on the side effect that GTK calls into GDK to take a grab before the
popup window is shown.

gdk/wayland/gdkdevice-wayland.c
gdk/wayland/gdkprivate-wayland.h
gdk/wayland/gdkwindow-wayland.c

index 7381d217b920b9b5702d37780c1b28058038bc5b..9e8e6b17d809a04354222016231b6721c5000872 100644 (file)
@@ -243,6 +243,15 @@ gdk_device_core_grab (GdkDevice    *device,
 
       wayland_device->pointer_grab_window = window;
       wayland_device->pointer_grab_time = time_;
+
+      /* FIXME: This probably breaks if you end up with multiple grabs on the
+       * same window - but we need to know the input device for when we are
+       * asked to map a popup window so that the grab can be managed by the
+       * compositor.
+       */
+      _gdk_wayland_window_set_device_grabbed (window,
+                                              wayland_device->device,
+                                              time_);
     }
 
   return GDK_GRAB_SUCCESS;
@@ -252,6 +261,7 @@ static void
 gdk_device_core_ungrab (GdkDevice *device,
                         guint32    time_)
 {
+  GdkWaylandDevice *wayland_device = GDK_DEVICE_CORE (device)->device;
   GdkDisplay *display;
   GdkDeviceGrabInfo *grab;
 
@@ -268,6 +278,10 @@ gdk_device_core_ungrab (GdkDevice *device,
 
       if (grab)
         grab->serial_end = grab->serial_start;
+
+      _gdk_wayland_window_set_device_grabbed (wayland_device->pointer_grab_window,
+                                              NULL,
+                                              0);
     }
 }
 
index de8d5cc2e6b74516e2f5166678b5864e059ae526..62815911f28767bf7d2bca337c9a1794e8fd8670 100644 (file)
@@ -146,4 +146,8 @@ void _gdk_wayland_display_manager_add_display (GdkDisplayManager *manager,
 void _gdk_wayland_display_manager_remove_display (GdkDisplayManager *manager,
                                                  GdkDisplay        *display);
 
+void _gdk_wayland_window_set_device_grabbed (GdkWindow *window,
+                                             struct wl_input_device *input_device,
+                                             guint32 time_);
+
 #endif /* __GDK_PRIVATE_WAYLAND_H__ */
index d76347bb4c6a0268ae5d1ed18ce47138cf779b95..cdadd47bcfe01c37a09c5df2fd31eb85de6bf587 100644 (file)
@@ -119,6 +119,9 @@ struct _GdkWindowImplWayland
 
   GdkGeometry geometry_hints;
   GdkWindowHints geometry_mask;
+
+  struct wl_input_device *grab_input_device;
+  guint32 grab_time;
 };
 
 struct _GdkWindowImplWaylandClass
@@ -1477,3 +1480,15 @@ _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
   impl_class->change_property = gdk_wayland_window_change_property;
   impl_class->delete_property = gdk_wayland_window_delete_property;
 }
+
+
+void
+_gdk_wayland_window_set_device_grabbed (GdkWindow              *window,
+                                        struct wl_input_device *input_device,
+                                        guint32                 time_)
+{
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+  impl->grab_input_device = input_device;
+  impl->grab_time = time_;
+}